package com.example.aftersales.utils;

import lombok.Data;

@Data
public class Result {
    private boolean success;
    private String message;
    private Object data;

    // 无参构造函数
    public Result() {
    }

    // 成功响应构造函数
    public Result(boolean success, String message) {
        this.success = success;
        this.message = message;
    }

    // 成功响应带数据构造函数
    public Result(boolean success, String message, Object data) {
        this.success = success;
        this.message = message;
        this.data = data;
    }

    // 成功响应
    public static Result success() {
        return new Result(true, "操作成功");
    }

    public static Result success(String message) {
        return new Result(true, message);
    }

    public static Result success(String message, Object data) {
        return new Result(true, message, data);
    }

    // 失败响应
    public static Result error() {
        return new Result(false, "操作失败");
    }

    public static Result error(String message) {
        return new Result(false, message);
    }
}